﻿Public Class Af2011Genel

	Shared Sub IndirimliCezaHesapla(Borc As Prim.Borc.Borc, donem01 As Input, donem02 As Input, donem11 As Input, donem12 As Input)
		'İndirimli cezaları hesapla
		'p: peşin ödemede ceza
		't: taksitli ödemede ceza
		For Each Donem In Borc.Donemler.Values
			For Each Ay In Donem.Aylar
				For Each Bordro In Ay.Bordrolar
					If donem11 Is Nothing Then
						Bordro.aktif = Donem.Donem >= donem01.Get AndAlso Donem.Donem <= donem02.Get
					Else
						Select Case Len(Bordro.tip)
							Case "1" : Bordro.aktif = Donem.Donem >= donem01.Get AndAlso Donem.Donem <= donem02.Get
							Case "2" : Bordro.aktif = donem11 Is Nothing OrElse (Donem.Donem >= donem11.Get AndAlso Donem.Donem <= donem12.Get)
						End Select
					End If
					Bordro.temp.Clear()
					If Bordro.aktif Then
						If Donem.Donem < "2000" Then
							Bordro.temp.Add("p.ceza", 0)
							Bordro.temp.Add("t.ceza", 0)
						ElseIf Donem.Donem < "2010" Then
							Bordro.temp.Add("p.ceza", Math.Round(Bordro.ceza * 0.2, 2))
							Bordro.temp.Add("t.ceza", Math.Round(Bordro.ceza * 0.3, 2))
						Else
							Bordro.temp.Add("p.ceza", Math.Round(Bordro.ceza * 0.1, 2))
							Bordro.temp.Add("t.ceza", Math.Round(Bordro.ceza * 0.3, 2))
						End If
					End If
				Next
			Next
		Next
		'Toplamları hesapla
		Dim Anapara(1) As Decimal
		For Each Donem In Borc.Donemler.Values
			If Donem.Aktif Then
				Anapara(If(Donem.Donem < "2000", 0, 1)) += Donem.Anapara
			End If
		Next
		'Peşin/taksitli dönemleri hesapla
		Dim Toplam(1) As Decimal
		For Each Donem In Borc.Donemler.Values
			If Donem.Aktif Then
				Dim t As Integer = If(Donem.Donem < "2000", 0, 1)
				Toplam(t) += Donem.Anapara
				Donem.PesinDurumu = If(Toplam(t) > Anapara(t) * 0.3 And Not Toplam(t) = Donem.Anapara, "T", "P")
			End If
		Next
	End Sub

End Class
